<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form ref="filterForm" :inline="true" :model="filterForm" label-position="left">
        <el-form-item label="账户类型" >
            <el-radio-group v-model="filterForm.simulation"  @input="handleFilter">
            <el-radio-button label="0">全部</el-radio-button>
            <el-radio-button label="2">真实</el-radio-button>
            <el-radio-button label="1">模拟</el-radio-button>
            </el-radio-group>
        </el-form-item>
        <el-form-item label="合约" >
          <el-input v-model="filterForm.symbol" placeholder="合约"  @input="handleFilter" />
        </el-form-item>
      </el-form>
    </div>
    <el-table
      :key="tableKey"
      v-loading="listLoading"
      :data="list"
      stripe
      border
      fit
      highlight-current-row
      style="width: 100%;"
      @sort-change="sortChange"
    >
      <el-table-column label="账户" align="center" fixed="left" width="150px">
          <template slot-scope="{row}">
            <span @click="handleMarket(row)">{{ row.accountID }}</span>
          </template>
      </el-table-column>
      <el-table-column label="资产" align="center" min-width="150px">
        <template slot-scope="{row}">
          <span>{{ row.capital }}</span>
        </template>
      </el-table-column>
      <el-table-column label="最新价格" align="center" min-width="150px">
        <template slot-scope="{row}">
          <span>{{ row.revenue }}</span>
        </template>
      </el-table-column>
      <el-table-column label="上市天数" align="center" width="100px">
        <template slot-scope="{row}">
          <span>{{ row.expenses }}</span>
        </template>
      </el-table-column>
      <el-table-column label="成交量" align="center" min-width="150px">
        <template slot-scope="{row}">
          <span>{{ row.withdraw }}</span>
        </template>
      </el-table-column>
      <el-table-column label="成交量" align="center" min-width="150px">
        <template slot-scope="{row}">
          <span>{{ row.deposit }}</span>
        </template>
      </el-table-column>
      <el-table-column label="成交量" align="center" min-width="150px">
        <template slot-scope="{row}">
          <span>{{ row.balance }}</span>
        </template>
      </el-table-column>
      <el-table-column label="持仓" align="center" min-width="150px">
        <template slot-scope="{row}">
          <span>{{ row.profit }}</span>
        </template>
      </el-table-column>
      <el-table-column label="成交量" align="center" min-width="150px">
        <template slot-scope="{row}">
          <span>{{ row.cost }}</span>
        </template>
      </el-table-column>
      <el-table-column label="加入时间" min-width="150px">
        <template slot-scope="{row}">
          <span>{{ row.cycle }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="filterForm.page" :limit.sync="filterForm.size" @pagination="getList" />
  </div>
</template>

<script>
//import { getFaultinessList,  removeFaultinessByID, changeFaultinessStatusByID } from '@/api/development/faultiness'
import waves from '@/directive/waves' // waves directive
import { parseTime } from '@/utils'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import {getHost} from '@/utils/socket' // secondary package based on el-pagination
import {getReviewList} from '@/api/finance/review'

export default {
  name: 'financeDashboard',
  components: { Pagination },
  directives: { waves },
  filters: {
  },
  data() {
    return {
      
      socket:"",
      tableKey: 0,
      list: null,
      windowHeight:"800",
      total: 0,
      listLoading: false,
      connected:"loading",
      cycleList:[],
      filterForm: {
        page: 1,
        size: 10,
        expireDate:'230807',
        style:"0",
        localSymbol: "I"
      }
    }
  },
  created() {
    this.getList()
  },
  destroyed(){
  },
  methods: {
    getList:function(){
      let _this = this;
      console.log(_this.filterForm)
      getReviewList(_this.filterForm).then((response) => {
        console.log(response)
          if (response.code === 200) {
            this.list = response.data.list
            this.total = response.data.total
          } else {
            _this.$message({
              message: response.msg,
              type: 'error'
            })
          }
      })
    },
    handleFilter() {
      this.filterForm.page = 1
      this.getList()
    },
    sortChange(data) {
      const { prop, order } = data
      if (prop === 'id') {
        this.sortByID(order)
      }
    },
    sortByID(order) {
      if (order === 'ascending') {
        this.filterForm.sort = '+id'
      } else {
        this.filterForm.sort = '-id'
      }
      this.handleFilter()
    }
  }
}
</script>
<style>

</style>